from typing import List


class Solution:
    def longestMountain(self, A: List[int]) -> int:
        top = []
        res = 0

        for i in range(len(A) - 1):
            if i != 0 and A[i - 1] < A[i] and A[i + 1] < A[i]:
                top.append(i)
        print(top)
        for v in top:
            p1 = p2 = v
            s1 = s2 = True
            while s1 or s2:
                if p1 > 0 and A[p1] > A[p1 - 1]:
                    p1 -= 1
                else:
                    s1 = False

                if p2 < len(A) - 1 and A[p2] > A[p2 + 1]:
                    p2 += 1
                else:
                    s2 = False
                print(p1, p2)
            if p2 != v and p1 != v:
                res = max(res, p2 - p1 + 1)
            print("res=", res, v, p2, p1)
        return res if res >= 3 else 0


if __name__ == "__main__":
    res = Solution().longestMountain([0, 1, 2, 3, 4])

    print(res)
